<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2024/12/4
  Time: 13:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>异步提交商品</title>
</head>
<body>
<form id="products">
    <table border="1">
        <tr>
        <tr>商品id</tr>
        <tr>商品名称</tr>
        <tr>提交</tr>
        </tr>
        <tr>
            <td><input name="proId" value="1" id="proId"></td>
            <td><input name="proName" value="三文鱼" id="proName"></td>
            <td><input type="button" value="提交单个订单" onabort="sumbmitProduct()"></td>
        </tr>
        <tr>
            <td><input name="proId" value="2" id="proId2"></td>
            <td><input name="proName" value="红牛" id="proName2"></td>
            <td><input type="button" value="提交多个商品" onabort="sumbmitProduct()"></td>
        </tr>
    </table>
</form>
</body>
<script src="static/js/jquery.min.js"></script>
<script>
    function summitProduct(){
        var proId= $("#proId").val();
        var proName= $("#proName").val();
        $.ajax({
            url:"/getProduct",
            type:"POST",
            date:JSON.stringify({"proId":proId,"proName":proName}),
            contentType:"application/json;charset=UTF-8",
            dataType:"json",
            success:function(response){
                alert(response);
            }
        })
    }
        function sumbmitProduct() {
            var pro1 = {proId: $(#proId).val(), proName: $(#proName).val()};
            var pro2 = {proId: $(#proId2).val(), proName: $(#proName2).val()};
            $.ajax({
                url: "/getProductList",
                type: "POST",
                date: JSON.stringify([pro1, pro2]),
                contentType: "application/json;charset=UTF-8",
                dataType: "json",
                success: function (response) {
                    alert(response);
                }
            })
        }
</script>
</html>
